#pragma once

#include "ui_render.h"
#include "ui_freetype_font_manager.h"

_SSL_BEGIN
_SSUIL_BEGIN

struct UIFtMaskImage
{
	ssbin buffer;
	int width;
	int height;
};

class UIFreetypeRenderUtil
{
public:
	static void DrawText(UIFreetypeFontManager *font_manager, HDC dc, const tchar *text, int text_len,
		unsigned long text_color, const UIRect *rt, const tstring& font_id, unsigned int style,
		bool transparent, unsigned long bk_color = 0);
	static bool MeasureTextSize(UIFreetypeFontManager *font_manager, const tchar *text, int text_len,
		ss_inout_ UIRect &rt, const tstring& font_id, UIMeasureTextType measure_type);

protected:
	static bool GenerateMaskImage(int width, int height, UIFtMaskImage &mask_img);
	static bool RenderCharOnMaskImage(UIFreetypeFontManager *font_manager, 
		UIFtMaskImage &mask_img, int x, int y, const UIFtCharInfo &ch);
	static bool RenderCharOnMaskImage(UIFtCharImgInfo *ch_img_info, 
		UIFtMaskImage &mask_img, int x, int y);
	static bool MaskText(ss_out_ UIFtMaskImage &mask_image, UIFreetypeFontManager *font_manager,
		const tchar *text, int text_len, int canvas_width, int canvas_height,
		const tstring& font_id, unsigned int style, bool measure_size, UISize *layout_size);
};

_SSUIL_END
_SSL_END

